#This document was created by R Markdown in R

R and Rstudio

Developed at the University of Auckland, New Zealand, in 1993, R is a specialized programming language for statistics and data analysis. Because R is distributed as an open-source project, it is free and is allowed to be modified and redistributed. In particular, social scientists have started to focus on R’s outstanding extensibility, which has led to R’s remarkable growth among statistical programs. Packages are one of the powerful features of R, with 15,503 currently registered (March 25, 2020) and added by users in real-time.

Rstudio is an Integrated Development Environment (IDE) software of R. IDE provides a programming environment where coding, debugging, compiling, and distributing can be addressed in one program. Moreover, Rstudio provides users an interface that is easier to use than R.

R(Left) and Rstudio(Right)

Packages for mapping and data visualization

R’s packages support producing various types of maps and graphs. For example, (1) a simple vector-based map can be created by map() package. (2) new spatial information can be added on Google Map with a combination of ggplot() and ggmap() packages. (3) a spatial analysis package, sp() package, allows users to use R as Geographic Information System. (4) R has been supporting to create an interactive web map since leaflet() package was first launched in June

library(htmltools); library(leaflet)
isu <- data.frame(Name=c("College of Design", "Memorial Union", "Parks Library"), Lat=c(42.0285, 42.0235, 42.0281), Long=c(-93.6532, -93.6458, -93.6487))
m1 <- leaflet(isu) %>% addTiles() %>% addMarkers(~Long, ~Lat, popup = ~htmlEscape(Name)); m1

Example or Project

library(leaflet); library(rgdal); library(geojsonio); library(htmltools)

eq <- geojsonio::geojson_read("eq.geojson", what = "sp")
popden <- geojsonio::geojson_read("pop_den.geojson", what = "sp")

pal <- colorNumeric("magma", NULL)

leaflet(popden) %>% addTiles(group = "OSM (Default Map)") %>%
  addProviderTiles(providers$CartoDB.Positron, group = "Cartographic Map") %>% 
  addProviderTiles(providers$Esri.NatGeoWorldMap, group = "National Geographic Map") %>% 
  addPolygons(weight = 0.5, color = "black", smoothFactor = 0.3, fillOpacity = 0.7, fillColor = ~pal(Density), group = "Population Density", label = ~paste0(County, " COUNTY: ", formatC(Density, big.mark = ","),
" per sq. mi.")) %>%
  addLegend("bottomright", colors =c("#303033",  "#3a384f", "#5b3c84", "#784193", "#8b4894", "#f9fac7"), labels=c("1.0-8.0", "8.0-19.5","19.5-96.0","96.0-350.6","350.6-483.6", "483.6-1274.7"), title= "POP Density 2015",
opacity = 1, group = "Population Density") %>% addTiles() %>%
  addMarkers(lng = eq$longitude, lat = eq$latitude, label = ~as.character(eq$mag), group = "Earthquakes") %>%
  addLayersControl(baseGroups = c("OSM (Default Map)", "Cartographic Map", "National Geographic Map"), overlayGroups = c("Earthquakes", "Population Density"), options = layersControlOptions(collapsed = FALSE))

Overall Evaluation

R language is not an easy programming language for first-time users. The challenge results from the features of the R language that enables programming as well as having various data analysis functions. Although the R language’s syntax composition seems complex compared to SPSS or STATA with a graphic interface, this language style not only helped R have the highest degree of freedom among statistic programs, but also helped users share code scripts. Because of these characteristics, R has a lot of user-centered communities and users share numerous R-related information.
- R-bloggers (https://www.r-bloggers.com)
- Cross Validated (https://stats.stackexchange.com)
The project was also carried out with shared information from numerous R users. Even though I had insufficient knowledge and experience to use R language, the vast R coding information in Google allowed me to write the code script to achieve my project goal. This experience made me believe that R could be the most common statistical program in the near future.

Resources or Dataset

eq.geojson
- Data Explanation: Earthquakes Information in Utah
- GitHub URL: https://andyjung82.github.io/CRP558/assignment2_geojson/utah_earthquake4.geojson
- Source Data URL: https://earthquake.usgs.gov/earthquakes/search/

pop_den.geojson
- Data Explanation: Population Density Information in 29 counties, Utah
- GitHub URL: https://andyjung82.github.io/CRP558/assignment2_geojson/pop_den.geojson
- Source Data URL: https://opendata.utah.gov/Government-and-Taxes/Population-Density-By-Land-Area-And-County-In-Utah/bzur-buif